﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using Baimasoft.FrameWork.Base;
using Baimasoft.Manage.SqlServerDAL;

public partial class BBS_BbsManage_GroupEdit : Baimasoft.Web.UI.PageFormTop 
{
    PMods MyPM = new PMods();
    
    public string sID = "";
    protected override void InitForm()
    {
        
        if (!Page.IsPostBack)
        {
            try
            {
                string sEditStatus = this.Request.QueryString["EditStatus"].ToString().Trim();
                if (sEditStatus == "2")
                {
                    sID = this.Request.QueryString["ID"].ToString().Trim();
                    SqlDataReader MySDR = MyPM.ReadPModsInfo("a.GroupID =" + sID);
                    if (MySDR.Read())
                    {
                        GroupName.Text = MySDR["GroupName"].ToString().Trim();
                        Descr.Text = MySDR["Descr"].ToString().Trim();
                        Ord.Text = MySDR["Ord"].ToString().Trim();
                        Visiable.Text = MySDR["Visiable"].ToString().Trim();
                    }
                }
            }
            catch
            {
            }
        }
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        string sGroupName = GroupName.Text.ToString().Trim();
        string sDescr = Descr.Text.ToString().Trim();
        string sOrd = Ord.Text.ToString().Trim();
        string sVisiable = Visiable.SelectedValue.ToString().Trim();

        if (this.EditStatus == EditStatus.Add)
        {
            int iback = MyPM.AddPMods(sGroupName, sDescr, sVisiable, sOrd);
            if (iback > 0)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('保存成功!');window.location.href='GroupList.aspx';</script>");
            }
        }
        else
        {
            DateTime UpDt = DateTime .Now ;
            int iback = MyPM.UpdatePMods(sGroupName, sDescr, sVisiable, sOrd, UpDt, this.Request.QueryString["ID"].ToString().Trim());
            if (iback > 0)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改成功!');window.location.href='GroupList.aspx';</script>");
            }
        }

    }
}
